﻿using Groep2TINGHService.Get_Set_Classes;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace Groep2TINGHService.DB_Classes
{
   public class RoleDB
    {
        public static List<Role> GetAllRoles()
        {
            List<Role> lijst = new List<Role>();
            SqlConnection connection = ConnectionDB.GetConnection();
            SqlCommand selectCommand = new SqlCommand("SELECT RoleName from aspnet_Roles",connection);

            try
            {
               
               Role temp;
               connection.Open();
               SqlDataReader reader = selectCommand.ExecuteReader();
               int RoleName = reader.GetOrdinal("RoleName");
               while (reader.Read())
               {
                   temp = new Role();
                   temp.RoleName = reader.GetString(RoleName);
                   lijst.Add(temp);
               }
               reader.Close();
            }
            catch (SqlException ex)
            {
                throw;
            }
            finally
            {
                connection.Close();
            }
            return lijst;
        }
    }
}
